class StatChampionship
{
	protected FootballScores fs;

	public StatChampionship(FootballScores fs)
	{
		this.fs = fs;
	}

	public int getMatchPlayed(String e)
	{
		int i=fs.findTeam(e), ct=0;
		if (i==-1) return -1;
		for (int j=0; j<fs.teams.length; j++)
			if (fs.scores[i][j] != null)
				ct++;
		return ct;
	}

	public int getWon(String e)
	{
		int i=fs.findTeam(e), ct=0;
		Point p;
		if (i==-1) return -1;
		for (int j=0; j<fs.teams.length; j++)
		{
			p = fs.scores[i][j];
			if (p!=null && p.getX()>p.getY()) ct++;
		}
		return ct;
	}

	public int getDraw(String e)
	{
		int i=fs.findTeam(e), ct=0;
		Point p;
		if (i==-1) return -1;
		for (int j=0; j<fs.teams.length; j++)
		{
			p = fs.scores[i][j];
			if (p!=null && p.getX()==p.getY()) ct++;
		}
		return ct;
	}

	public int getLost(String e)
	{
		int i=fs.findTeam(e), ct=0;
		Point p;
		if (i==-1) return -1;
		for (int j=0; j<fs.teams.length; j++)
		{
			p = fs.scores[i][j];
			if (p!=null && p.getX()<p.getY()) ct++;
		}
		return ct;
	}

	public int getFor(String e)
	{
		int i=fs.findTeam(e), ct=0;
		if (i==-1) return -1;
		for (int j=0; j<fs.teams.length; j++)
			if (fs.scores[i][j]!=null)
				ct += fs.scores[i][j].getX();
		return ct;
	}

	public int getAgainst(String e)
	{
		int i=fs.findTeam(e), ct=0;
		if (i==-1) return -1;
		for (int j=0; j<fs.teams.length; j++)
			if (fs.scores[i][j]!=null)
				ct += fs.scores[i][j].getY();
		return ct;
	}

	public int getDifference(String e)
	{
		return getFor(e)-getAgainst(e);
	}

	public int getPoints(String e)
	{
		return getFor(e)*3 + getDraw(e);
	}

	public TeamStatistics getStats(String e)
	{
		return new TeamStatistics(
				e,
				getMatchPlayed(e),
				getWon(e),
				getDraw(e),
				getLost(e),
				getFor(e),
				getAgainst(e),
				getDifference(e),
				getPoints(e)
			);
	}

	public String toString()
	{
		String res = "";
		for (String p: fs.teams)
			res += getStats(p)+"\n";
		return res;
	}

	public void printStat()
	{
		System.out.print(toString());
	}
}
